{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "219bf13c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#列表的私有方法\n",
    "from typing import List, Union, Any\n",
    "\n",
    "stu_id = [10000,10001,10002,10003,10004,10005,10006,10007,10008,10009,10001,10001]\n",
    "\n",
    "names = ['Mike','Mary','Jay','Kuro']\n",
    "\n",
    "## 1.增加 append() 增加在list的末尾\n",
    "# names.append(1)\n",
    "print(names)\n",
    "\n",
    "## 2.插入 insert()可以指定位置增加元素\n",
    "# names.insert(1,'yougege')\n",
    "print(\"insert()方法后的names:\",names)\n",
    "\n",
    "## 2. 删除 remove 和 pop\n",
    "## 2.1 remove()一般情况下 使用remove先用in做判断\n",
    "# if 1 in names\n",
    "#    names.remove(1)\n",
    "# print(\"remove删除的结果:\",names)\n",
    "\n",
    "## 2.2 pop() 删除位置为1的元素\n",
    "names.pop(1)\n",
    "print(\"pop()方法的names:\",names)\n",
    "\n",
    "## 3. index()索引 查看该元素如10001 在stu_id中第一个出现的位置索引\n",
    "print(stu_id.index(10001))\n",
    "\n",
    "## 4. clear()清除所有数据\n",
    "# names.clear()\n",
    "# print(\"清除names列表后的值:\",names)\n",
    "\n",
    "## 5.count()查看列表元素出现的个数，(简单应用)统计分数出现的次数\n",
    "# print(\"count方法的结果:\",stu_id.count(10001))\n",
    "#print(names)\n",
    "\n",
    "## 6. extend() 是给指定的list进行补充\n",
    "names.extend(stu_id)\n",
    "#print(names)\n",
    "\n",
    "\n",
    "##作业: list方法的总结,list的切片的总结\n",
    "#列表的其他方法(Sequence Types 的一些方法)\n",
    "## 1.len()查看list的长度\n",
    "print(\"names的长度/names的列表元素个数：\",len(names))\n",
    "## 2.in查看元素是否在list当中,结果为布尔值, False/True\n",
    "## 一般在操作list的修改和删除时会为判断\n",
    "print(\"luoyu\" in names)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
